<?php
require_once(__DIR__."/../DB/DB.php");
session_start();
/**
 * Created by PhpStorm.
 * User: zhang
 * Date: 2016/9/23
 * Time: 10:59
 */
$username=$_POST['username'];
$password=sha1($_POST['password']);
$dbConn=DB::get_instance();
  if(!empty($username) && !empty($password))
  {
     $sql="select username,password from user where username='{$username}' and password='{$password}'";
      $row=$dbConn->select($sql,$one=true);
      if($row){
          $_SESSION['username']=$row['username'];
          header("location:../index.php");
      }else{
          echo "
      <script type='text/javascript'>
      alert('用户名或者密码不正确');
      location.href='../pages/examples/login.html';
      </script>
      ";
      }
  }else{
      echo "
      <script type='text/javascript'>
      alert('用户名或者密码不能为空');
      location.href='../pages/examples/login.html';
      </script>
      ";
  }

